/* 1800. 最大升序子数组和 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var maxAscendingSum = function (nums) {
	let ans = nums[0] || 0
	const len = nums.length
	for (let i = 0; i < len - 1; i++) {
		let temp = nums[i]
		let j = i + 1
		let prev = nums[i]
		while (j < len && nums[j] > prev) {
			temp += nums[j]
			prev = nums[j]
			j++
		}
		i = j === i + 1 ? i : j - 1
		ans = Math.max(ans, temp)
	}
	return ans
}
// 动态规划
var maxAscendingSum = function (nums) {
	let res = 0
	let l = 0
	while (l < nums.length) {
		let cur = nums[l++]
		while (l < nums.length && nums[l] > nums[l - 1]) {
			cur += nums[l++]
		}
		res = Math.max(res, cur)
	}
	return res
}
var maxAscendingSum = function (nums) {
	let ans = nums[0]
	for (let i = 1, cur = nums[0]; i < nums.length; i++) {
		if (nums[i] > nums[i - 1]) {
			cur += nums[i]
		} else {
			cur = nums[i]
		}
		ans = Math.max(ans, cur)
	}
	return ans
}
const ans = maxAscendingSum([10])
console.log('maxAscendingSum :>>', ans)
